import React, {Component} from 'react'
import {View, Text, TextInput, TouchableOpacity} from 'react-native'
import {PostFeedbackApi} from '../../config/api'
import styles from '../../config/styles'

class Feedback extends Component {
    constructor (props) {
        super(props)
        this.state = {
            content: ""
        }
    }

    submit = () => {
        PostFeedbackApi(this.state.content).then((data) => {
            if (data.code == 0) {
                Toast.show('反馈成功，感谢您的意见')
            } else {
                Toast.show('网络错误，请稍后重试')
            }
            this.props.navigation.goBack()
        })
    }

    render () {
        return (
            <View style={styles.main_body}>
                 <TextInput
                    placeholder={'请输入您的意见'}
                    onChangeText={(txt) => {this.setState({content: txt})}}
                    style={{height: 150, padding: 0, backgroundColor: 'white'}}
                    multiline={true}
                    textAlignVertical={'top'}
                    underlineColorAndroid="transparent"
                    blurOnSubmit={true}
                    value={this.state.content}
                />
                 <TouchableOpacity
                    style={[styles.as_large_button, styles.background_blue, {marginTop: 10}]}
                    onPress={this.submit}   
                >
                    <Text style={{color: 'white'}}>提交</Text>
                </TouchableOpacity>
            </View>
        )
    }
}

// const styles = StyleSheet.create({
//     button_style: {
//         paddingLeft: 85,
//         paddingRight: 85,
//         padding: 10,
//         backgroundColor: '#0066FF',
//         borderRadius: 5,
//         justifyContent: 'center', 
//         alignItems: 'center',
//         elevation: 10,
//         marginTop: 15
//     }
// })

export default Feedback